-- 公会成员战功奖励弹窗
local GuildWarGuildMemberAwardPop = class("GuildWarGuildMemberAwardPop", app.mvc.ViewBase)
local GuildWarGuildMemberAwardCell = import("..renders.GuildWarGuildMemberAwardCell")
local CrossServerGuildWarHelper = require("app.crossServer.views.guildWar.CrossServerGuildWarHelper")
local ListViewVertical = require("app.widget.listview.ListViewVertical")

GuildWarGuildMemberAwardPop.VIEW_ROOT_RES = Res.CSGuildWarGuildMemberAward

function GuildWarGuildMemberAwardPop:init()
    self.super.init(self)
    display.setCascadeOpacityEnabled(self._root, true)
    self._ui.Button_close:addClickEventListener(function()
        self:closeView()
    end)

    self._ui.btn_rank:addClickEventListener(function()
        self:closeView()
        -- app:sendMsg("CrossServerController", "popGuildWarGuildScore")
        app:sendMsg("CrossServerController", "openGuildWarViewPanelByIndex", 4)
        -- UIHandler:handleMessage({id = Constant.FUNC_TYPE_RANK,mode = "open", rankingId = Enums.GuildRankType.CSTotalCombatPower})
    end)
    local params = {
        renderClass = GuildWarGuildMemberAwardCell,   
    }
    self:registerViewEvent({
        {name = ViewEvent.Common_TipsClose, callback = handler(self, self.closeView)},
    })

    self._listview = ListViewVertical.new(self._ui["Panel/ScrollView"], params)
end


function GuildWarGuildMemberAwardPop:setRank(guildRank)
    self._listviewData = CrossServerGuildWarHelper.getAwardByRank(guildRank)
    self:refresh()
end

function GuildWarGuildMemberAwardPop:refresh()
    self._listview:reloadData(self._listviewData or {})
end

return GuildWarGuildMemberAwardPop